package com.len.controller;

import com.len.entity.Campaign;
import com.len.service.MarketMonitorService;
import com.len.util.ReType;
import com.len.vo.ParameterInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author xiangyang
 * @Date 2019-01-16
 */
@Controller
@RequestMapping("/market")
public class MarketController {

    @Autowired
    MarketMonitorService marketMonitorService;


    /**
     * 获取table数据
     * @param info
     * @return
     * @throws Exception
     */
    @ApiOperation(value = "/loadKeyWordTableData", httpMethod = "POST", notes = "关键词表格数据")
    @PostMapping(value = "loadKeyWordTableData")
    @ResponseBody
    public ReType loadKeyWordTableData(ParameterInfo info) throws Exception {
        return marketMonitorService.loadKeyWordTableData(info);
    }

    /**
     * 根据字典类型获取字典数据
     * @param dicType
     * @return
     * @throws Exception
     */
    @ApiOperation(value = "/loadsDictionaryByType", httpMethod = "POST", notes = "字典数据")
    @PostMapping(value = "loadsDictionaryByType")
    @ResponseBody
    public ReType loadsDictionaryByType(Campaign campaign) throws Exception {
        return marketMonitorService.loadsDictionaryByType(campaign);
    }

    @GetMapping("/market")
    public String market() {
        return "market";
    }

}
